/**
 */
;
(function(){
'use strict';
	
	var app = angular.module('fwa.mainApp');
	app.controller('WarningResultNoticeCtrl', ['$scope','$modal','$modalInstance','$http','$state', '$location','$stateParams','WarningAddService','BaseURL','Modal',
	    function ($scope,$modal,$modalInstance,$http,$state,$location,$stateParams,WarningAddService,baseUrl,Modal) {
		$scope.warningAddService=WarningAddService;
		 $scope.resultNotice = {};  	   
		 $scope.resultNotice.date = {};
		initWarnNoticeDialog();
		function initWarnNoticeDialog(){			
			if(!!WarningAddService.warningResultNotice.name){
				$scope.resultNotice.name=WarningAddService.warningResultNotice.name;
				$scope.resultNotice.tel=WarningAddService.warningResultNotice.tel;	
				$scope.resultNotice.address=WarningAddService.warningResultNotice.address;	
				$scope.resultNotice.date.start=WarningAddService.warningResultNotice.datestart;
				$scope.resultNotice.date.end=WarningAddService.warningResultNotice.dateend;
				$scope.resultNotice.problem=WarningAddService.warningResultNotice.problem;				
				$scope.resultNotice.decide=WarningAddService.warningResultNotice.decide;	
				$scope.resultNotice.invalidCost=WarningAddService.warningResultNotice.invalidCost;	
			}			
		}				  	
 	    	 //关闭事件
			  $scope.onClose = function() {					  
				 $modalInstance.dismiss();
			  }					  
			  //保存事件
			  $scope.warningResultNoticeDialog = function() {				 
				  if(!$scope.resultNotice.name)
					{
						Modal.alert("单位名称不能为空!");
						return;
					} 
				 
					if(!$scope.resultNotice.tel)
					{
						Modal.alert("联系电话不能为空!");
						return;
					}
					if(!$scope.resultNotice.address)
					{
						Modal.alert("单位地址不能为空!");
						return;
					}
					
					if(!$scope.resultNotice.date.start)
					{
						Modal.alert("预警开始时段不能为空!");
						return;
					}
					if(!$scope.resultNotice.date.end)
					{
						Modal.alert("预警结束时段不能为空!");
						return;
					}
					if(!$scope.resultNotice.problem)
					{
						Modal.alert("存在问题不能为空!");
						return;
					}
					WarningAddService.warningResultNotice.name=$scope.resultNotice.name;
					WarningAddService.warningResultNotice.tel=$scope.resultNotice.tel;	
					WarningAddService.warningResultNotice.address=$scope.resultNotice.address;	
					WarningAddService.warningResultNotice.datestart=$scope.resultNotice.date.start;
					WarningAddService.warningResultNotice.dateend=$scope.resultNotice.date.end;
					WarningAddService.warningResultNotice.problem=$scope.resultNotice.problem;				
					WarningAddService.warningResultNotice.decide=$scope.resultNotice.decide;	
					WarningAddService.warningResultNotice.invalidCost=$scope.resultNotice.invalidCost;
					$modalInstance.dismiss();
			  }
			
	}]);
})();